Telegram Group & Telegram Channel
Команда дня: pipe

Сегодня делимся полезной фишкой из библиотеки pandas — метод .pipe() для создания чистых и читаемых цепочек обработки данных.

import pandas as pd

# Пример: очистка и преобразование данных в одну цепочку
def clean_data(df):
return df.dropna().reset_index(drop=True)

def add_age_group(df):
df['age_group'] = pd.cut(df['age'], bins=[0, 18, 35, 60, 100], labels=['Kid', 'Young', 'Adult', 'Senior'])
return df

# Используем pipe для последовательной обработки
df = (pd.read_csv('data.csv')
.pipe(clean_data)
.pipe(add_age_group))


Зачем это нужно:
🎌 .pipe() позволяет организовать преобразования данных в логическую цепочку, улучшая читаемость кода
🎌 Удобно для сложных ETL-процессов (Extract, Transform, Load)
🎌 Легко добавлять новые шаги обработки

Пример в деле:
def normalize_column(df, col):
df[col] = (df[col] - df[col].mean()) / df[col].std()
return df

df = (pd.DataFrame({'value': [10, 20, 30, 40]})
.pipe(normalize_column, col='value'))


Библиотека дата-сайентиста #буст
Please open Telegram to view this post
VIEW IN TELEGRAM



tg-me.com/dsproglib/6423
Create:
Last Update:

Команда дня: pipe

Сегодня делимся полезной фишкой из библиотеки pandas — метод .pipe() для создания чистых и читаемых цепочек обработки данных.

import pandas as pd

# Пример: очистка и преобразование данных в одну цепочку
def clean_data(df):
return df.dropna().reset_index(drop=True)

def add_age_group(df):
df['age_group'] = pd.cut(df['age'], bins=[0, 18, 35, 60, 100], labels=['Kid', 'Young', 'Adult', 'Senior'])
return df

# Используем pipe для последовательной обработки
df = (pd.read_csv('data.csv')
.pipe(clean_data)
.pipe(add_age_group))


Зачем это нужно:
🎌 .pipe() позволяет организовать преобразования данных в логическую цепочку, улучшая читаемость кода
🎌 Удобно для сложных ETL-процессов (Extract, Transform, Load)
🎌 Легко добавлять новые шаги обработки

Пример в деле:
def normalize_column(df, col):
df[col] = (df[col] - df[col].mean()) / df[col].std()
return df

df = (pd.DataFrame({'value': [10, 20, 30, 40]})
.pipe(normalize_column, col='value'))


Библиотека дата-сайентиста #буст

BY Библиотека дата-сайентиста | Data Science, Machine learning, анализ данных, машинное обучение


Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283

Share with your friend now:
tg-me.com/dsproglib/6423

View MORE
Open in Telegram


Библиотека data scientist’а | Data Science Machine learning анализ данных машинное обучение Telegram | DID YOU KNOW?

Date: |

How to Use Bitcoin?

n the U.S. people generally use Bitcoin as an alternative investment, helping diversify a portfolio apart from stocks and bonds. You can also use Bitcoin to make purchases, but the number of vendors that accept the cryptocurrency is still limited. Big companies that accept Bitcoin include Overstock, AT&T and Twitch. You may also find that some small local retailers or certain websites take Bitcoin, but you’ll have to do some digging. That said, PayPal has announced that it will enable cryptocurrency as a funding source for purchases this year, financing purchases by automatically converting crypto holdings to fiat currency for users. “They have 346 million users and they’re connected to 26 million merchants,” says Spencer Montgomery, founder of Uinta Crypto Consulting. “It’s huge.”

Telegram and Signal Havens for Right-Wing Extremists

Since the violent storming of Capitol Hill and subsequent ban of former U.S. President Donald Trump from Facebook and Twitter, the removal of Parler from Amazon’s servers, and the de-platforming of incendiary right-wing content, messaging services Telegram and Signal have seen a deluge of new users. In January alone, Telegram reported 90 million new accounts. Its founder, Pavel Durov, described this as “the largest digital migration in human history.” Signal reportedly doubled its user base to 40 million people and became the most downloaded app in 70 countries. The two services rely on encryption to protect the privacy of user communication, which has made them popular with protesters seeking to conceal their identities against repressive governments in places like Belarus, Hong Kong, and Iran. But the same encryption technology has also made them a favored communication tool for criminals and terrorist groups, including al Qaeda and the Islamic State.

Библиотека data scientist’а | Data Science Machine learning анализ данных машинное обучение from sg


Telegram Библиотека дата-сайентиста | Data Science, Machine learning, анализ данных, машинное обучение
FROM USA